package com.kotlin.android.app.ui.fragment

import android.content.Intent
import com.android.app.router.event.EventLoginState
import com.kotlin.android.app.ui.QuanbuActivity
import com.kotlin.android.app.R
import com.kotlin.android.app.databinding.FragmentWoDeBinding
import com.kotlin.android.app.ui.LoginActivity
import com.kotlin.android.core.BaseVMFragment
import com.kotlin.android.core.BaseViewModel
import com.kotlin.android.ktx.ext.click.onClick
import com.kotlin.android.ktx.ext.immersive.immersive
import com.kotlin.android.media.image.coil.loadImage
import com.kotlin.android.router.bus.ext.observe


class WoDeFragment : BaseVMFragment<BaseViewModel, FragmentWoDeBinding>() {
    companion object {
        fun newInstance() = WoDeFragment()
    }

    override fun initTheme() {
        super.initTheme()
        immersive().statusBarDarkFont(true)
    }

    override fun initView() {
        //            maxWidth = screenWidth
//            maxHeight = screenWidth * 5 //这里其实可以根据需求而定，我这里测试为最大宽度的5倍
        mBinding?.imageIv?.apply {
            loadImage(R.drawable.wode_unlogin)
            onClick {
                Intent(requireContext(), LoginActivity::class.java).apply {

                }.also {
                    startActivity(it)
                }
            }
        }
    }

    override fun startObserve() {
        observe(EventLoginState::class.java) {
            mBinding?.imageIv?.apply {
                loadImage(R.drawable.wode_login)
                onClick {
                    Intent(requireContext(), QuanbuActivity::class.java).apply {

                    }.also {
                        startActivity(it)
                    }
                }
            }
        }
    }

    override fun initData() {
    }
}